# 自定义过滤器
def index_class(index):
    if index == 1:
        return "first"
    elif index == 2:
        return "second"
    elif index == 3:
        return "third"
    else:
        return ""


from flask import session, g
# 封装用户的登陆信息


def user_login_data(view_func):
    def wrapper(*args, **kwargs):
        user_id = session.get('user_id')

        user = None
        if user_id:
            from info.models import User
            user = User.query.get(user_id)
        g.user = user
        return view_func(*args, **kwargs)
    return wrapper
